<?= kvframework_markup::form_remote_tag(array("update" => 'box', "url" => self::url_for('appointment', 'create_form_process'), 302 => "hideBox(true);", "loading" => 'doLoading2(true);', "complete" => "doLoading2(false);")) ?>
<table border="0" cellspacing="0">
  <tbody>
    <tr>
      <td class="leftward">
        <div class="title"><h1><?= ($this->reschedule) ? "Rescheduling" : "New" ?> appointment</h1><div class="cancelbutton"><a href="#" onclick="hideBox(false);">cancel</a></div></div>
        <div id="insetbox">
          <div id="leftpane">
          <input type="hidden" name="step" id="step" />
          <input type="hidden" name="max_step" id="max_step" value="<?= $this->max_step ?>" />

          <input type="hidden" name="date" id="date" value="<?= TOOLS::date_to_s($this->date) ?>" />
          <input type="hidden" name="starttime" id="starttime" value="<?= TOOLS::time_to_s($this->start) ?>" />
          <input type="hidden" name="stoptime" id="stoptime" value="<?= TOOLS::time_to_s($this->stop) ?>" />
          <input type="hidden" name="consultant" id="consultant" value="<?= $this->thisguy->id ?>" />

          <input type="hidden" name="fi[appttype_id]" id="fi[appttype_id]" value="<?= $this->appttype_id ?>" />
          <input type="hidden" name="fi[repeat]" id="fi[repeat]" value="<?= $this->repeat ?>" />
          <input type="hidden" name="fi[multi_user]" id="fi[multi_user]" value="<?= $this->multi_user ?>" />
          <input type="hidden" name="fi[special2]" id="fi[special2]" value="<?= $this->special2 ?>" />

          <input type="hidden" name="other_consultants" id="other_consultants" value="<?= implode(",",$this->other_rcs) ?>" />

          <?php if($this->reschedule) { ?>
            <input type="hidden" name="reschedule" id="reschedule" value="<?= $this->reschedule ?>" />
          <?php } ?>

          <input type="hidden" name="fi[loc_id]" id="fi[loc_id]" value="<?= $this->loc_id ?>" />
          <input type="hidden" name="fi[locdetails]" id="fi[locdetails]" value="<?= $this->locdetails ?>" />

          <?php if($this->thing) { ?>
            <input type="hidden" name="tid" id="tid" value="<?= $this->thing->id ?>" />
            <input type="hidden" name="ttype" id="ttype" value="<?= $this->thing->tm_type ?>" />
          <?php } else { ?>
            <?php if ($this->type == "Ticket") { ?>
              <input type="hidden" name="fi[withperson]" id="fi[withperson]" value="<?= $this->withperson ?>" />
              <input type="hidden" name="fi[phone]" id="fi[phone]" value="<?= $this->phone ?>" />
              <input type="hidden" name="fi[altphone]" id="fi[altphone]" value="<?= $this->altphone ?>" />
              <input type="hidden" name="fi[ticket]" id="fi[ticket]" value="<?= $this->ticket ?>" />
            <?php } elseif ($this->type == "Meeting" || $this->type == "Meecket") { ?>
              <input type="hidden" name="fi[subject]" id="fi[subject]" value="<?= $this->subject ?>" />
            <?php } ?>
            <input type="hidden" name="fi[details]" id="fi[details]" value="<?= $this->details ?>" />
          <?php } ?>

          <?php if ($this->foverride) { ?>
            <input type="hidden" name="fi[foverride]" id="fi[foverride]" value="yes" />
          <?php } else { ?>
            <input type="hidden" name="fi[foverride]" id="fi[foverride]" value="no" />
          <?php } ?>

	  <?php foreach($this->concur_override as $loctag => $answ)
          { ?>
                    <input type="hidden" name="concur_override[<?=$loctag?>]" id="concur_override_<?=$loctag?>" value="<?= $answ ?>" />
          <?php } ?>
          <input type="hidden" name="length_override" id="length_override" value="<?= $this->length_override ?>" />
          <input type="hidden" name="time_conf" id="time_conf" value="<?= $this->time_override ?>" />
          <input type="hidden" name="finals_conf" id="finals_conf" value="<?= $this->finals_override ?>" />
          <input type="hidden" name="dist_conf" id="dist_conf" value="<?= $this->far_override ?>" />
          <input type="hidden" name="appthour_override" id="appthour_override" value="<?= $this->appthour_override ?>" />
          <input type="hidden" name="gen_conf" id="gen_conf" value="<?= $this->gender_override ?>" />

            Date and Time: <?= TOOLS::date_to_s($this->date) ?> from <?= TOOLS::time_to_s($this->start, true) ?> to <?= TOOLS::mytime_select(array("display12h" => true, "selected" => $this->stop, "name" => 'stoptime', "on_minutes" => 30, "min_hour" => (int)TOOLS::hour_s_for($this->start), "max_hour" => (int)TOOLS::hour_s_for($this->stopmax))) ?> (max: <?= TOOLS::time_to_s($this->stopmax, true) ?><input type="hidden" name="fi[stopmax]" id="fi[stopmax]" value="<?= TOOLS::time_to_s($this->stopmax) ?>" />)<br />
            Type: <?= ($this->special2 == "meeting") ? "Meeting" : (($this->special2 == "meecket") ? "Special Appointment" : "Regular Appointment") ?> for <?= Appttype::select_name($this->appttype) ?><br />
            <?= ($this->multi_user == "TRUE") ? "With Multiple Consultants<br />" : "" ?>
            Consultants: <?= Consultant::select_name($this->thisguy) ?><br />
            <br />

            <div class="line">End Date:</div>
            <div class="line2 date_selector"><?= TOOLS::date_select(array( "selected" => ($this->enddate) ? $this->enddate : $this->date, "name" => "fi[enddate]", "start_year" => TOOLS::year_for($this->date), "end_year" => TOOLS::year_for($this->date) + 5, "class" => 'txtbox2_nowidth')) ?></div>

            <div class="line">Repetition Days?</div>
            <div class="line2"><?= kvframework_markup::select(array("name" => "repetition_day[]", "values" => TOOLS::options_from_wdays_allowed($this->appttype->weekdays_allowed), "selected" => ((is_array($this->rep_day) && count($this->rep_day) != 0) ? $this->rep_day : array(TOOLS::weekday_transform(TOOLS::wday_for($this->date)))), "class" => 'txtbox2_noheight', "size" => 7, "multiple" => 'multiple')) ?></div>

            <div class="line">On Weeks:</div>
            <div class="line2"><?= kvframework_markup::select(array("name" => "fi[repetition_week]", "values" => TOOLS::array_collect(TOOLS::int_range(1, 10), '$i', 'array($i, $i)'), "selected" => (($this->rep_week) ? $this->rep_week : 1 ), "class" => 'txtbox2')) ?></div>
          </div>
        </div>
        <div class="button"><input type="submit" value="back" onclick="document.getElementById('step').value = 'prev';" class="btn" /><input type="submit" value="next" class="btn" /></div>
      </td>
      <td class="spacer"></td>
      <td class="rightward">
        <?= $this->outputMessages() ?>
        <?= $this->outputErrors() ?>
      </td>
    </tr>
  </tbody>
</table>
<input type="hidden" name="thisstep" id="thisstep" value="repeat" />
</form>
